<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>OA登录</title>
    <meta name="description" content="系统登陆"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link rel="shortcut icon" href="/assets/img/favicon.png" type="image/x-icon">
    <link href="/assets/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
    <link href="/assets/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>
    <link href="/assets/css/font-sans.min.css" rel="stylesheet" type="text/css"/>
    <link href="/assets/css/beyond.min.css" rel="stylesheet" type="text/css"/>
    <script>
        var csss = ['/assets/css/page.css'];
        for (m = 0; m < csss.length; m++) {
            document.write('<link href="' + csss[m] + '?license=' + new Date().getTime() + '" rel="stylesheet" />');
        }
    </script>
    <link href="/assets/css/typicons.min.css" rel="stylesheet" type="text/css"/>
    <link href="/assets/css/animate.min.css" rel="stylesheet" type="text/css"/>
    <script src="/assets/js/jquery.min.js"></script>
    <script src="/assets/js/jquery.cookie.js"></script>
    <script src="/assets/js/bootstrap.min.js"></script>
</head>
<body>
<div class="login-container animated fadeInDown">
    <div class="loginbox bg-white">
        <div class="loginbox-title"></div>
        <div class="loginbox-social">
            <div class="social-title ">Connect with Your Social Accounts</div>
            <div class="social-buttons">
                <a href="#" class="button-facebook">
                    <i class="social-icon fa fa-facebook"></i>
                </a>
                <a href="#" class="button-twitter">
                    <i class="social-icon fa fa-twitter"></i>
                </a>
                <a href="#" class="button-google">
                    <i class="social-icon fa fa-google-plus"></i>
                </a>
            </div>
        </div>
        <div class="loginbox-or">
            <div class="or-line"></div>
            <div class="or">OR</div>
        </div>
        <form id="defaultForm" method="post" class="form-horizontal" role="form">
            <div class="form-group">
                <div class="loginbox-textbox">
                    <label for="loginName">用户名</label><input id="loginName" name="loginName" type="text"
                                                             class="form-control" placeholder="账号"
                                                             value="wangbolin"/>
                </div>
                <div class="loginbox-textbox">
                    <label for="password">密码</label><input id="password" name="password" type="password"
                                                           class="form-control" placeholder="密码"
                                                           value="1234567"/>
                </div>
                <div class="loginbox-forgot">
                    <a href="#">忘记密码?</a>
                </div>
                <div class="loginbox-submit">
                    <input id="btnLogin" type="submit" class="btn btn-primary btn-block" value="登录"
                           data-loading-text="登录中...">
                </div>
                <div class="loginbox-signup">
                    <a href="register.html">使用邮箱注册</a>
                </div>
            </div>
        </form>
    </div>
</div>
<script src="/assets/js/slimscroll/jquery.slimscroll.min.js"></script>
<script src="/assets/js/beyond.js"></script>
<script src="/assets/js/skins.min.js"></script>
<script type="text/javascript">
    var jss = ['/assets/js/webapp.js', '/assets/js/jquery-1.10.2.plugin.js',
        '/assets/js/validation/jquery.bootvalidate.js'];
    for (n = 0; n < jss.length; n++) {
        document.write('<script src="' + jss[n] + '?license=' + new Date().getTime() + '"><' + "/" + 'script>');
    }
</script>
<script type="text/javascript">

    $(document).ready(function () {
        var validateParam = {
            submitHandler: function (obj) {
                $("#btnLogin").button('loading');
                $.request('/admin/sys/user/login', obj, function (result) {
                    if (result) {
                        $.removeCookie(app.name + '_token');
                        $.removeCookie(app.name + '_userId');
                        $.removeCookie(app.name + '_name');
                        $.removeCookie(app.name + '_loginName');
                        $.removeCookie(app.name + '_orgId');
                        $.cookie(app.name + '_token', result.token);
                        $.cookie(app.name + '_orgId', result.orgId);
                        //$.cookie(app.name + '_email', result.email ? result.email : "");
                        $.cookie(app.name + '_userId', result.id);
                        $.cookie(app.name + '_name', result.nikeName);
                        $.cookie(app.name + '_loginName', result.loginName);
                        window.location.href = '/index.html?license=' + new Date().getTime();
                    } else {
                        $.removeCookie(app.name + '_token');
                        $.removeCookie(app.name + '_userId');
                        $.removeCookie(app.name + '_name');
                        $.removeCookie(app.name + '_loginName');
                        $.removeCookie(app.name + '_orgId');
                    }
                }).always(function () {
                    $("#btnLogin").button('reset');
                });
            },
            fields: {
                loginName: {
                    validators: {
                        notEmpty: {}
                    }
                },
                password: {
                    validators: {
                        notEmpty: {}
                    }
                }
            }
        };
        $('#defaultForm').validate(validateParam);
    });
</script>
</body>
</html>